home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / c / pthd-0.000 / pthd-0 / pthd-0.7 / include / dce / pthread_exc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-16  |  11.6 KB  |  546 lines

  1. /*
  2.  * 
  3.  * (c) Copyright 1991 OPEN SOFTWARE FOUNDATION, INC.
  4.  * (c) Copyright 1991 HEWLETT-PACKARD COMPANY
  5.  * (c) Copyright 1991 DIGITAL EQUIPMENT CORPORATION
  6.  * To anyone who acknowledges that this file is provided "AS IS"
  7.  * without any express or implied warranty:
  8.  *                 permission to use, copy, modify, and distribute this
  9.  * file for any purpose is hereby granted without fee, provided that
  10.  * the above copyright notices and this notice appears in all source
  11.  * code copies, and that none of the names of Open Software
  12.  * Foundation, Inc., Hewlett-Packard Company, or Digital Equipment
  13.  * Corporation be used in advertising or publicity pertaining to
  14.  * distribution of the software without specific, written prior
  15.  * permission.  Neither Open Software Foundation, Inc., Hewlett-
  16.  * Packard Company, nor Digital Equipment Corporation makes any
  17.  * representations about the suitability of this software for any
  18.  * purpose.
  19.  * 
  20.  */
  21. /*
  22.  */
  23. /*
  24. */
  25. #ifndef PTHREAD_EXC_H
  26. #define PTHREAD_EXC_H
  27. /*
  28. **
  29. **  NAME:
  30. **
  31. **      pthread_exc.h
  32. **
  33. **  FACILITY:
  34. **
  35. **      Remote Procedure Call (RPC) 
  36. **
  37. **  ABSTRACT:
  38. ** 
  39. **  Exception-raising Pthread API header file.
  40. **
  41. **  The exception-raising Pthread API is just like the regular Pthread API
  42. **  except that errors in Pthread functions are indicated by raising exceptions
  43. **  rather than by returning error codes.
  44. ** 
  45. **
  46. **  %a%private_end  
  47. ** 
  48. */
  49.  
  50. #include <pthread.h>
  51. #include <dce/exc_handling.h>
  52.  
  53. #if 0                      /* @@ */
  54.  
  55. /*   #include <dce/pthread_np.h>   @@ */
  56.  
  57. /* --------------------------------------------------------------------------- */
  58.  
  59. #ifdef __STDC__
  60. #   define _PTDEXC_PROTO_(x) x
  61. #else
  62. #   define _PTDEXC_PROTO_(x) ()
  63. #endif
  64.  
  65. /* --------------------------------------------------------------------------- */
  66.  
  67. extern EXCEPTION pthread_badparam_e;            /* Bad parameter */
  68. extern EXCEPTION pthread_existence_e;           /* Object does not exist */
  69. extern EXCEPTION pthread_in_use_e;              /* Object is in use */
  70. extern EXCEPTION pthread_use_error_e;           /* Object inappropriate for operation */
  71. extern EXCEPTION pthread_nostackmem_e;          /* No memory to allocate stack */
  72. extern EXCEPTION pthread_exit_thread_e;         /* Used to terminate a thread */
  73.  
  74. /* --------------------------------------------------------------------------- */
  75.  
  76. #ifndef _PTDEXC_NOWRAP_
  77.  
  78. #define pthread_attr_create(attr) \
  79.     ptdexc_attr_create(attr)
  80.  
  81. #define pthread_attr_delete(attr) \
  82.     ptdexc_attr_delete(attr)
  83.  
  84. #define pthread_attr_setprio(attr,priority) \
  85.     ptdexc_attr_setprio(attr,priority)
  86.  
  87. #define pthread_attr_getprio(attr) \
  88.     ptdexc_attr_getprio(attr)
  89.  
  90. #define pthread_attr_setsched(attr,scheduler) \
  91.     ptdexc_attr_setsched(attr,scheduler)
  92.  
  93. #define pthread_attr_getsched(attr) \
  94.     ptdexc_attr_getsched(attr)
  95.  
  96. #define pthread_attr_setinheritsched(attr,inherit) \
  97.     ptdexc_attr_setinheritsched(attr,inherit)
  98.  
  99. #define pthread_attr_getinheritsched(attr) \
  100.     ptdexc_attr_getinheritsched(attr)
  101.  
  102. #define pthread_attr_setstacksize(attr,stacksize) \
  103.     ptdexc_attr_setstacksize(attr,stacksize)
  104.  
  105. #define pthread_attr_getstacksize(attr) \
  106.     ptdexc_attr_getstacksize(attr)
  107.  
  108. #define pthread_create(thread,attr,start_routine,arg) \
  109.     ptdexc_create(thread,attr,start_routine,arg)
  110.  
  111. #define pthread_detach(thread) \
  112.     ptdexc_detach(thread)
  113.  
  114. #define pthread_join(thread,status) \
  115.     ptdexc_join(thread,status)
  116.  
  117. #define pthread_setprio(thread,priority) \
  118.     ptdexc_setprio(thread,priority)
  119.  
  120. #define pthread_getprio(thread) \
  121.     ptdexc_getprio(thread)
  122.  
  123. #define pthread_mutexattr_create(attr) \
  124.     ptdexc_mutexattr_create(attr)
  125.  
  126. #define pthread_mutexattr_delete(attr) \
  127.     ptdexc_mutexattr_delete(attr)
  128.  
  129. #define pthread_mutex_init(mutex,attr) \
  130.     ptdexc_mutex_init(mutex,attr)
  131.  
  132. #define pthread_mutex_destroy(mutex) \
  133.     ptdexc_mutex_destroy(mutex)
  134.  
  135. #define pthread_mutex_lock(mutex) \
  136.     ptdexc_mutex_lock(mutex)
  137.  
  138. #define pthread_mutex_trylock(mutex) \
  139.     ptdexc_mutex_trylock(mutex)
  140.  
  141. #define pthread_mutex_unlock(mutex) \
  142.     ptdexc_mutex_unlock(mutex)
  143.  
  144. #define pthread_condattr_create(attr) \
  145.     ptdexc_condattr_create(attr)
  146.  
  147. #define pthread_condattr_delete(attr) \
  148.     ptdexc_condattr_delete(attr)
  149.  
  150. #define pthread_cond_init(cond,attr) \
  151.     ptdexc_cond_init(cond,attr)
  152.  
  153. #define pthread_cond_destroy(cond) \
  154.     ptdexc_cond_destroy(cond)
  155.  
  156. #define pthread_cond_broadcast(cond) \
  157.     ptdexc_cond_broadcast(cond)
  158.  
  159. #define pthread_cond_signal(cond) \
  160.     ptdexc_cond_signal(cond)
  161.  
  162. #define pthread_cond_timedwait(cond,mutex,abstime) \
  163.     ptdexc_cond_timedwait(cond,mutex,abstime)
  164.  
  165. #define pthread_once(once_block,init_routine) \
  166.     ptdexc_once(once_block,init_routine)
  167.  
  168. #define pthread_keycreate(key,destructor) \
  169.     ptdexc_keycreate(key,destructor)
  170.  
  171. #define pthread_setspecific(key,value) \
  172.     ptdexc_setspecific(key,value)
  173.  
  174. #define pthread_getspecific(key,value) \
  175.     ptdexc_getspecific(key,value)
  176.  
  177. #define pthread_cancel(thread) \
  178.     ptdexc_cancel(thread)
  179.  
  180. #ifdef OSF
  181. #ifdef pthread_setasynccancel
  182. #undef pthread_setasynccancel
  183. #endif
  184. #ifdef pthread_setcancel
  185. #undef pthread_setcancel
  186. #endif
  187. #endif
  188.  
  189. #define pthread_setasynccancel(state) \
  190.     ptdexc_setasynccancel(state)
  191.  
  192. #define pthread_setcancel(state) \
  193.     ptdexc_setcancel(state)
  194.  
  195. #endif
  196.  
  197. /* --------------------------------------------------------------------------- */
  198.  
  199. /*
  200.  * Operations to define thread creation attributes
  201.  */
  202.            
  203. /*
  204.  * Create the attribute.
  205.  */
  206. int
  207. ptdexc_attr_create
  208.     _PTDEXC_PROTO_((
  209.         pthread_attr_t          *attr
  210.     ));
  211.  
  212. /*
  213.  * Set or obtain the default thread priority.
  214.  */
  215. void
  216. ptdexc_attr_setprio
  217.     _PTDEXC_PROTO_((
  218.         pthread_attr_t          *attr,
  219.         int                     priority
  220.     ));
  221.  
  222. int
  223. ptdexc_attr_getprio
  224.     _PTDEXC_PROTO_((
  225.         pthread_attr_t          attr
  226.     ));
  227.  
  228. /*
  229.  * Set or obtain the default scheduling algorithm
  230.  */
  231. void
  232. ptdexc_attr_setsched
  233.     _PTDEXC_PROTO_((
  234.         pthread_attr_t          *attr,
  235.         int                     scheduler
  236.     ));
  237.  
  238. int
  239. ptdexc_attr_getsched
  240.     _PTDEXC_PROTO_((
  241.         pthread_attr_t          attr
  242.     ));
  243.  
  244. /*
  245.  * Set or obtain whether a thread will use the default scheduling attributes,
  246.  * or inherit them from the creating thread.
  247.  */
  248. void
  249. ptdexc_attr_setinheritsched
  250.     _PTDEXC_PROTO_((
  251.         pthread_attr_t          *attr,
  252.         int                     inherit
  253.     ));
  254.  
  255. int
  256. ptdexc_attr_getinheritsched
  257.     _PTDEXC_PROTO_((
  258.         pthread_attr_t          attr
  259.     ));
  260.  
  261. /*
  262.  * Set or obtain the default stack size
  263.  */
  264. void
  265. ptdexc_attr_setstacksize
  266.     _PTDEXC_PROTO_((
  267.         pthread_attr_t          *attr,
  268.         long                    stacksize
  269.     ));
  270.  
  271. long
  272. ptdexc_attr_getstacksize
  273.     _PTDEXC_PROTO_((
  274.         pthread_attr_t          attr
  275.     ));
  276.  
  277. /*
  278.  * The following procedures can be used to control thread creation,
  279.  * termination and deletion.
  280.  */
  281.  
  282. /*
  283.  * To create a thread object and runnable thread, a routine must be specified
  284.  * as the new thread's start routine.  An argument may be passed to this
  285.  * routine, as an untyped address; an untyped address may also be returned as
  286.  * the routine's value.  An attributes object may be used to specify details
  287.  * about the kind of thread being created.
  288.  */
  289. void
  290. ptdexc_create
  291.     _PTDEXC_PROTO_((
  292.         pthread_t               *thread,
  293.         pthread_attr_t          attr,
  294.         void                    *(*start_routine)(void *srarg),
  295.         void                    *arg
  296.     ));
  297.  
  298. /*
  299.  * A thread object may be "detached" to specify that the return value and
  300.  * completion status will not be requested.
  301.  */
  302. void
  303. ptdexc_detach
  304.     _PTDEXC_PROTO_((
  305.         pthread_t               *thread
  306.     ));
  307.  
  308. /* 
  309.  * A thread can await termination of another thread and retrieve the return
  310.  * value of the thread.
  311.  */
  312. void
  313. ptdexc_join
  314.     _PTDEXC_PROTO_((
  315.         pthread_t               thread,
  316.         void                    **status
  317.     ));
  318.  
  319. /*
  320.  * Thread Scheduling Operations
  321.  */
  322.  
  323. /*
  324.  * The current user_assigned priority of a thread can be changed.
  325.  */
  326. int
  327. ptdexc_setprio
  328.     _PTDEXC_PROTO_((
  329.         pthread_t               thread,
  330.         int                     priority
  331.     ));
  332.  
  333. /*
  334.  * Thread Information Operations
  335.  */
  336.  
  337. /*
  338.  * The current user_assigned priority of a thread can be read.
  339.  */
  340. int
  341. ptdexc_getprio
  342.     _PTDEXC_PROTO_((
  343.         pthread_t               thread
  344.     ));
  345.  
  346. /*
  347.  * Operations on Mutexes
  348.  */
  349.  
  350. void
  351. ptdexc_mutexattr_create
  352.     _PTDEXC_PROTO_((
  353.         pthread_mutexattr_t     *attr
  354.     ));
  355.  
  356. void
  357. ptdexc_mutexattr_delete
  358.     _PTDEXC_PROTO_((
  359.         pthread_mutexattr_t     *attr
  360.     ));
  361.  
  362. /* 
  363.  * The following routines create, delete, lock and unlock mutexes.
  364.  */
  365. void
  366. ptdexc_mutex_init
  367.     _PTDEXC_PROTO_((
  368.         pthread_mutex_t         *mutex,
  369.         pthread_mutexattr_t     attr
  370.     ));
  371.  
  372. void
  373. ptdexc_mutex_destroy
  374.     _PTDEXC_PROTO_((
  375.         pthread_mutex_t         *mutex
  376.     ));
  377.  
  378. void
  379. ptdexc_mutex_lock
  380.     _PTDEXC_PROTO_((
  381.         pthread_mutex_t         *mutex
  382.     ));
  383.  
  384. int
  385. ptdexc_mutex_trylock
  386.     _PTDEXC_PROTO_((
  387.         pthread_mutex_t         *mutex
  388.     ));
  389.  
  390. void
  391. ptdexc_mutex_unlock
  392.     _PTDEXC_PROTO_((
  393.         pthread_mutex_t         *mutex
  394.     ));
  395.  
  396. /*
  397.  * Operations on condition variables
  398.  */
  399.  
  400. void
  401. ptdexc_condattr_create
  402.     _PTDEXC_PROTO_((
  403.         pthread_condattr_t      *attr
  404.     ));
  405.  
  406. void
  407. ptdexc_condattr_delete
  408.     _PTDEXC_PROTO_((
  409.         pthread_condattr_t      *attr
  410.     ));
  411.  
  412. /*
  413.  * A thread can create and delete condition variables.
  414.  */
  415. void
  416. ptdexc_cond_init
  417.     _PTDEXC_PROTO_((
  418.         pthread_cond_t          *cond,
  419.         pthread_condattr_t      attr
  420.     ));
  421.  
  422. void
  423. ptdexc_cond_destroy
  424.     _PTDEXC_PROTO_((
  425.         pthread_cond_t          *cond
  426.     ));
  427.  
  428. /*
  429.  * A thread can signal to and broadcast on a condition variable.
  430.  */
  431. void
  432. ptdexc_cond_broadcast
  433.     _PTDEXC_PROTO_((
  434.         pthread_cond_t          *cond
  435.     ));
  436.  
  437. void
  438. ptdexc_cond_signal
  439.     _PTDEXC_PROTO_((
  440.         pthread_cond_t          *cond
  441.     ));
  442.  
  443. /*
  444.  * A thread can wait for a condition variable to be signalled or broadcast.
  445.  */
  446. void
  447. ptdexc_cond_wait
  448.     _PTDEXC_PROTO_((
  449.         pthread_cond_t          *cond,
  450.         pthread_mutex_t         *mutex
  451.     ));
  452.  
  453. /*
  454.  * Operations for timed waiting
  455.  */
  456.  
  457. /*
  458.  * A thread can perform a timed wait on a condition variable.
  459.  */
  460. int
  461. ptdexc_cond_timedwait
  462.     _PTDEXC_PROTO_((
  463.         pthread_cond_t          *cond,
  464.         pthread_mutex_t         *mutex,
  465.         struct timespec         *abstime
  466.     ));
  467.  
  468. /*
  469.  * Operations for client initialization.
  470.  */
  471.  
  472. void
  473. ptdexc_once
  474.     _PTDEXC_PROTO_((
  475.         pthread_once_t          *once_block,
  476.         void (*init_routine)()
  477.     ));
  478.  
  479. /*
  480.  * Operations for per-thread context
  481.  */
  482.  
  483. /*
  484.  * A unique per-thread context key can be obtained for the process
  485.  */
  486. void
  487. ptdexc_keycreate
  488.     _PTDEXC_PROTO_((
  489.         pthread_key_t           *key,
  490.         void                    (*destructor)(void *value)
  491.     ));
  492.  
  493. /*
  494.  * A thread can set a per-thread context value identified by a key.
  495.  */
  496. void
  497. ptdexc_setspecific
  498.     _PTDEXC_PROTO_((
  499.         pthread_key_t           key,
  500.         void                    *value
  501.     ));
  502.  
  503. /*
  504.  * A thread can retrieve a per-thread context value identified by a key.
  505.  */
  506. void
  507. ptdexc_getspecific
  508.     _PTDEXC_PROTO_((
  509.         pthread_key_t           key,
  510.         void                    **value
  511.     ));
  512.  
  513. /*
  514.  * Operations for alerts.
  515.  */
  516.  
  517. /*
  518.  * The current thread can request that a thread terminate it's execution.
  519.  */
  520.  
  521. void
  522. ptdexc_cancel
  523.     _PTDEXC_PROTO_((
  524.         pthread_t               thread
  525.     ));
  526.  
  527. /*
  528.  * The current thread can enable or disable alert delivery (PTHREAD
  529.  * "cancels"); it can control "general cancelability" (CMA "defer") or
  530.  * just "asynchronous cancelability" (CMA "asynch disable").
  531.  */
  532. int
  533. ptdexc_setasynccancel
  534.     _PTDEXC_PROTO_((
  535.         int                     state
  536.     ));
  537.  
  538. int
  539. ptdexc_setcancel
  540.     _PTDEXC_PROTO_((
  541.         int                     state
  542.     ));
  543.  
  544. #endif
  545.  
  546. #endif         /* #if 0 */